<?php
session_start();
//包含头
include '../PHP/head.php';
?>
<?php
//包含bootstrap的顶端按钮
include '../PHP/menu.php';
?>


<br />
<br />
<p class="text-center lead">提交文件列表</p>


<?php
//引用必要的函数
require_once ('../FNS/db_fns.php');

	$project_id = $_GET['project_id'];
	//把这个项目的所有文件搜出来
	//还需要获取提交人
	$query="select files.type, files.id, files.name, files.issue_date, files.rev, files.check_date, files.check_result, files.issuer, a.name as issue_name, b.name as check_name from files 
		left join users as a on files.issuer = a.id 
		left join users as b on files.checker = b.id
		left join task_list on files.task_id = task_list.id 
		where task_list.project_id ='".$project_id."'";

//连接数据库并搜索数据
$db= db_connect();
$result=$db->query ($query);
if (!$result) {
	echo "</div>";
	echo "</body>";
	echo "</html>";
	exit;
}
//获取记录数量
$num_results=$result->num_rows;
//echo "<p>记录条数是：".$num_results."</p>";
//写表头
echo "<table class='table table-striped'>";
echo "<tr>";
	echo "<td align='center' class='info'><strong>文件名</strong></td>";
	echo "<td align='center' class='info'><strong>版本号</strong></td>";
	echo "<td align='center' class='info'><strong>提出人</strong></td>";
	echo "<td align='center' class='info'><strong>提出时间</strong></td>";
	echo "<td align='center' class='info'><strong>校核人</strong></td>";
	echo "<td align='center' class='info'><strong>校核时间</strong></td>";
	echo "<td align='center' class='info'><strong>校核结论</strong></td>";
	echo "<td align='center' class='info'><strong>操作</strong></td>";
echo "</tr>";



//循环编制表格
for ($i=0; $i < $num_results; $i++) {

	$row=$result->fetch_assoc ();
	
	
	$files_id = stripslashes ($row['id']);
	$name = stripslashes ($row['name']);
	$rev = stripslashes ($row['rev']);
	$issuer = stripslashes ($row['issue_name']);
	$issuer_id = stripslashes ($row['issuer']);
	$checker = stripslashes ($row['check_name']);
	$type = stripslashes ($row['type']);
	//$checker = "结构专业负责人";
	$issue_date = stripslashes ($row['issue_date']);
	$check_date = stripslashes ($row['check_date']);
	$check_result = stripslashes ($row['check_result']);
	
	if ($type == "底价") {
	$link_ok = "../PHP/show_cost_issue.php?files_id=".$files_id."&checked=ok";
	$link_back = "../PHP/show_cost_issue.php?files_id=".$files_id."&checked=back";
	$download_link = "../PHP/download_file.php?file_name=".$name."_Rev.".$rev."_".$issuer_id.".xlsx";
	}
	if ($type == "标书") {
	$link_ok = "../PHP/show_proposal_issue.php?files_id=".$files_id."&checked=ok";
	$link_back = "../PHP/show_proposal_issue.php?files_id=".$files_id."&checked=back";
	$download_link = "../PHP/download_file.php?file_name=".$name."_Rev.".$rev."_".$issuer_id.".pdf";
	}
	
	echo "<tr>";
    echo "<td align ='center'>".$name."</td>";
	echo "<td align ='center'>".$rev."</td>";
	echo "<td align ='center'>".$issuer."</td>";
	echo "<td align ='center'>".$issue_date."</td>";
	echo "<td align ='center'>".$checker."</td>";
	echo "<td align ='center'>".$check_date."</td>";
	echo "<td align ='center'>".$check_result."</td>";
	if ($check_result) {
		echo "<td align='center'>
		<a class='btn btn-success btn-sm' href='".$download_link."' target='_blank' role='button'>下载</a> 
		</td>";
	} else {
	
	echo "<td align='center'>
		未校核
		</td>";
	}
	echo "</tr>";
	
}
echo "</table>";
$result->free();
$db->close();

?>

</div>
</body>
</html>
